// Agent basis
/* agent perceives an area that is a square with the size N with
the agent in the center. Each agent is able to see N*N cells. */

/* Initial beliefs and rules */
/* BELIEFS */
/* RULES */

/* initial DESIRES */
!search.

/* INTENTIONS (PLANS AND ACTIONS) */

+!search : pos(_,_,_) & cow(_,Cx,Cy)
<- +target(Cx,Cy);
   !move.
   
+!search : pos(_,_,_)
<- !move;
   -pos(_,_,_);
   !search.
   
+!search : not pos(_,_,_)
<- .print("I am alive. I dont know my pos");
   .wait("+pos(_,_,_)");
   .print("I know my pos");
   !search.
   
+!move : pos(X,Y,_) & target(Cx,Cy) & Cx \== X & Cy \== Y
<- .print("move to target");
   massim.jason.acao.FindPos( X, Y, Cx, Cy, NewX,NewY );
   massim.jason.acao.FindDirection(X,Y,NewX,NewY,Direction);
   moveTo(Direction);
   !move.
   
+!move : pos(X,Y,_) & target(Cx,Cy) & Cx == X & Cy == Y
<- .print("I am at target");
   -target(Cx,Cy).
   
+!move : pos(X,Y,_)
<- .print("Selecting a new position randomly...");
   massim.jason.acao.RandomPos(X, Y, NewX, NewY);
   .print("Discovering the new position direction...");
   massim.jason.acao.FindDirection(X, Y, NewX, NewY, Direction);
   moveTo(Direction).
   